<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>libdill</title>
  <link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>

<h1>libdill: Structured Concurrency for C</h1>

<ul id='toplist'>
<li><a href="index.html">Home</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="tutorial.html">Tutorials</a></li>
<li><a href="faq.html">FAQ</a></li>
</ul>
<h1 id="name">NAME</h1>
<p>ipc_pair_mem - creates a pair of mutually connected IPC sockets</p>
<h1 id="synopsis">SYNOPSIS</h1>
<div class="sourceCode"><pre class="sourceCode c"><code class="sourceCode c"><span class="pp">#include </span><span class="im">&lt;libdill.h&gt;</span>

<span class="dt">int</span> ipc_pair_mem(
    <span class="kw">struct</span> ipc_pair_storage* mem,
    <span class="dt">int</span> s[<span class="dv">2</span>]);</code></pre></div>
<h1 id="description">DESCRIPTION</h1>
<p>This function creates a pair of mutually connected IPC sockets.</p>
<p>This function allows to avoid one dynamic memory allocation by storing the object in user-supplied memory. Unless you are hyper-optimizing use <strong>ipc_pair</strong> instead.</p>
<p><strong>mem</strong>: The structure to store the newly created object in. It must not be deallocated before the object is closed.</p>
<p><strong>s</strong>: Out parameter. Two handles to the opposite ends of the connection.</p>
<p>The sockets can be cleanly shut down using <strong>ipc_close</strong> function.</p>
<h1 id="return-value">RETURN VALUE</h1>
<p>In case of success the function returns 0. In case of error it returns -1 and sets <strong>errno</strong> to one of the values below.</p>
<h1 id="errors">ERRORS</h1>
<ul>
<li><strong>ECANCELED</strong>: Current coroutine was canceled.</li>
<li><strong>EMFILE</strong>: The maximum number of file descriptors in the process are already open.</li>
<li><strong>ENFILE</strong>: The maximum number of file descriptors in the system are already open.</li>
<li><strong>ENOMEM</strong>: Not enough memory.</li>
</ul>
<h1 id="example">EXAMPLE</h1>
<div class="sourceCode"><pre class="sourceCode c"><code class="sourceCode c"><span class="dt">int</span> s[<span class="dv">2</span>];
<span class="dt">int</span> rc = ipc_pair(s);</code></pre></div>
<h1 id="see-also">SEE ALSO</h1>
<p><strong>hclose</strong>(3) <strong>ipc_accept</strong>(3) <strong>ipc_accept_mem</strong>(3) <strong>ipc_close</strong>(3) <strong>ipc_connect</strong>(3) <strong>ipc_connect_mem</strong>(3) <strong>ipc_done</strong>(3) <strong>ipc_fromfd</strong>(3) <strong>ipc_fromfd_mem</strong>(3) <strong>ipc_listen</strong>(3) <strong>ipc_listen_mem</strong>(3) <strong>ipc_listener_fromfd</strong>(3) <strong>ipc_listener_fromfd_mem</strong>(3) <strong>ipc_pair</strong>(3)</p>
</body>
